layui.use([ 'form', 'layer' ], function() {
	var form  = layui.form, 
	    layer = layui.layer;
	var id = $('#id').val();
	form.verify({
		loginPwdConfirm: function(value, item){
			var formData = form.val('resetPwdForm');
			var loginPwd = formData.loginPwd ;
			if(loginPwd!=value)
				return "新密码与确认密码不一致，请重新修改！";
		},
		loginPwdSrc:function(value,item){
			var formData = form.val('resetPwdForm');
			if(value==formData.loginPwd){
				return "新密码与旧密码相同，请重新设置！";
			}
		}
	});  
	// 监听提交
	form.on('submit(save)', function(data) {
		var formData = form.val('resetPwdForm');
		var loginPwd = formData.loginPwd ;
		var base = new Base64();
		loginPwd = base.encode(loginPwd);
		formData["loginPwd"] = loginPwd ;
		$.ajax({
			type:'POST',
			url:layui.cache['contentPath']+'/sys-user/modifyPwd',
			data:JSON.stringify(formData),
			contentType: "application/json",
			success:function(rs){
				rs = eval('('+rs+')');
				if(rs.code==0){
					layer.msg("操作成功",{icon:1,time:3000});
					// 关闭当前frame
					xadmin.close();
				}else{
					layer.msg(rs.msg,{icon:2,time:3000});
				}
			},
			error:function(status,errors){
				layer.alert('请求错误，错误码：'+JSON.stringify(status));
			}
		});
		return false;
	});
});